package de.baumann.browser.views.dialog

import android.content.Context
import android.widget.Toast
import de.baumann.browser.R
import kotlinx.android.synthetic.main.dialog_licence_gift.*

/**
 *@author:
 *@date:2019/7/10 16:50
 *@discription: Licence 赠送
 */
class LicenceGiftDialog(context: Context, private var giftNowLisntener: OnGiftNowLisntener) : BaseDialog(context) {

    override fun laoutId(): Int {
        return R.layout.dialog_licence_gift
    }

    override fun initView() {
        btnGiftNow.setOnClickListener {
            val account = getReceiveAccount()
            if (account.isEmpty()) {
                Toast.makeText(context,context.getString(R.string.intput_receiving_account),Toast.LENGTH_SHORT).show()
                return@setOnClickListener
            }
            dismiss()
            giftNowLisntener.giftNow(account)
        }
    }

    private fun getReceiveAccount(): String {
        return edReceiveAccount.text.trim().toString()
    }


    interface OnGiftNowLisntener {
        fun giftNow(account: String)
    }
}